Skip to content

[ImportVerilog] Emit coroutines for tasks#10070

Open
fabianschuiki wants to merge 1 commit intofschuiki/moore-coroutinesfrom
fschuiki/emit-coroutines
Open

[ImportVerilog] Emit coroutines for tasks#10070
fabianschuiki wants to merge 1 commit intofschuiki/moore-coroutinesfrom
fschuiki/emit-coroutines

Conversation

@fabianschuiki
Copy link
Copy Markdown
Contributor

Change ImportVerilog to emit moore.coroutine for SystemVerilog tasks and moore.call_coroutine for task calls. Functions continue to use func.func and func.call. This distinction is important because tasks can suspend execution via timing controls, while functions cannot.

The FunctionLowering struct now stores a FunctionOpInterface that is either a func::FuncOp or a moore::CoroutineOp, which provides all the common function-like operations without additional dispatch.

@fabianschuiki
Copy link
Copy Markdown
Contributor Author

Results of circt-tests run for 512cf9f compared to results for 8f20da9:

sv-tests

Changes in emitted diagnostics:

  • -12 total change
  • -7 error: 'llhd.wait' op expects parent op to be one of 'llhd.process, llhd.coroutine'
  • -6 error: 'llhd.halt' op expects parent op to be one of 'llhd.process, llhd.final, llhd.coroutine'
  • -3 error: failed to legalize operation 'moore.vtable'
  • +3 error: 'moore.vtable_entry' op cannot resolve target symbol to a function operation @"myclass::subtask"
  • -1 error: Queue element reference couldn't be reduced to setting the value at an index: consuming op "func.call"(%32) <{callee = @fun}> : (!moore.ref<i32>) -> () is not supported
  • -1 error: failed to legalize operation 'func.call'
  • +1 error: Queue element reference couldn't be reduced to setting the value at an index: consuming op "moore.call_coroutine"(%32) <{callee = @fun}> : (!moore.ref<i32>) -> () is not supported
  • +1 error: failed to legalize operation 'arith.select'
  • +1 error: failed to legalize operation 'moore.conversion'

@fabianschuiki fabianschuiki force-pushed the fschuiki/moore-coroutines branch from 8f20da9 to 9dfe8dc Compare March 27, 2026 22:52
@fabianschuiki fabianschuiki force-pushed the fschuiki/emit-coroutines branch from 512cf9f to 584376f Compare March 27, 2026 22:52
Change ImportVerilog to emit `moore.coroutine` for SystemVerilog tasks
and `moore.call_coroutine` for task calls. Functions continue to use
`func.func` and `func.call`. This distinction is important because
tasks can suspend execution via timing controls, while functions cannot.

The `FunctionLowering` struct now stores a `FunctionOpInterface` that
is either a `func::FuncOp` or a `moore::CoroutineOp`, which provides
all the common function-like operations without additional dispatch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@fabianschuiki fabianschuiki force-pushed the fschuiki/moore-coroutines branch from 9dfe8dc to 0080246 Compare March 27, 2026 23:15
@fabianschuiki fabianschuiki force-pushed the fschuiki/emit-coroutines branch from 584376f to 8b63571 Compare March 27, 2026 23:15
@fabianschuiki
Copy link
Copy Markdown
Contributor Author

Results of circt-tests run for 584376f compared to results for d676ea7:

sv-tests

Changes in emitted diagnostics:

  • -12 total change
  • -7 error: 'llhd.wait' op expects parent op to be one of 'llhd.process, llhd.coroutine'
  • -6 error: 'llhd.halt' op expects parent op to be one of 'llhd.process, llhd.final, llhd.coroutine'
  • -3 error: failed to legalize operation 'moore.vtable'
  • +3 error: 'moore.vtable_entry' op cannot resolve target symbol to a function operation @"myclass::subtask"
  • -1 error: Queue element reference couldn't be reduced to setting the value at an index: consuming op "func.call"(%32) <{callee = @fun}> : (!moore.ref<i32>) -> () is not supported
  • -1 error: failed to legalize operation 'func.call'
  • +1 error: Queue element reference couldn't be reduced to setting the value at an index: consuming op "moore.call_coroutine"(%32) <{callee = @fun}> : (!moore.ref<i32>) -> () is not supported
  • +1 error: failed to legalize operation 'arith.select'
  • +1 error: failed to legalize operation 'moore.conversion'

@fabianschuiki
Copy link
Copy Markdown
Contributor Author

Results of circt-tests run for 8b63571 compared to results for 0080246:

sv-tests

Changes in emitted diagnostics:

  • -12 total change
  • -7 error: 'llhd.wait' op expects parent op to be one of 'llhd.process, llhd.coroutine'
  • -6 error: 'llhd.halt' op expects parent op to be one of 'llhd.process, llhd.final, llhd.coroutine'
  • -3 error: failed to legalize operation 'moore.vtable'
  • +3 error: 'moore.vtable_entry' op cannot resolve target symbol to a function operation @"myclass::subtask"
  • -1 error: Queue element reference couldn't be reduced to setting the value at an index: consuming op "func.call"(%32) <{callee = @fun}> : (!moore.ref<i32>) -> () is not supported
  • -1 error: failed to legalize operation 'func.call'
  • +1 error: Queue element reference couldn't be reduced to setting the value at an index: consuming op "moore.call_coroutine"(%32) <{callee = @fun}> : (!moore.ref<i32>) -> () is not supported
  • +1 error: failed to legalize operation 'arith.select'
  • +1 error: failed to legalize operation 'moore.conversion'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant